<!--<embed type="text/html" src="/static/index/public/public/account_head.html" width="100%" height="140px"/>-->
{include file="public/account_head"}
<div class="pub_wid notice_cont" id="facilitator">
    <div class="mes_left rg">
        <div class="message bgb widthauto radius">
            <h6>运力服务商</h6>
            <div class="order_details">
                <ul>
                    <li @click="changeStatus(0)" class="fortab prepaids " :class="{'checked':status==0}">全部</li>
                    <li @click="changeStatus(1)" class="fortab prepaids2" :class="{'checked':status==1}">待审核</li>
                    <li @click="changeStatus(2)" class="fortab prepaids3" :class="{'checked':status==2}">已通过</li>
                    <li @click="changeStatus(3)" class="fortab prepaids4" :class="{'checked':status==3}">未通过</li>
                </ul>
            </div>
            <div>
                <div class="tablelist showdomdiv showsss"  >
                    <div class="bgb member_box">
                        <div class="table_head widthauto"><span class="sma">ID</span><span class="name">公司名称</span><span class="sma">状态</span><span class="oper">操作</span> </div>
                        <ul class="widthauto middl_ul">
                            <li v-for="(item,index) in facilitatorList">
                                <span class="sma">{{(((current_page-1)*num)+index)+1}}</span>
                                <span class="name">{{item.company_name}}</span>
                                <span class="sma " :class="[item.status==1?'ing':'',item.status==2?'ok':'',item.status==3?'end':'']">{{status_message[item.status-1]}}</span>
                                <span class="oper" v-if="item.status==1">
                                    <a class="two lf" @click="updateStatus(item,2)">通过</a>
                                    <a class="two rg" @click="updateStatusReject(item,3)">拒绝</a>
                                </span>
                                <span class="oper" v-if="item.status==2"><a :href="'/index/consignor/detail/id/'+item.member_id" class="one">查看企业详情资料</a></span>
                            </li>
<!--                            <li><span class="sma">2</span><span class="name">浙江新天力容器科技有限公司</span> <span class="sma end">已拒绝</span></li>-->
<!--                            <li><span class="sma">3</span><span class="name">浙江新天力容器科技有限公司</span> <span class="sma ok">已通过</span><span class="oper"><a href="#" class="one">查看企业详情资料</a></span></li>-->
                        </ul>
                    </div>
                    <div v-if="facilitatorListShow" class="widthauto pages_box">
                        <a @click="pageNumGetList(1)">首页</a>
                        <a @click="pageNextList(-1)">上一页</a>
<!--                        <a v-for="item in pageInfo.total"  @click="pageNumGetList(item)">{{item}}</a>-->
                        <a v-for="(item,index) in pageInfo.total" :class="(index+1)==current_page?'pages_box_cur':''" @click="pageNumGetList(item)">{{item}}</a>
                        <a @click="pageNextList(1)">下一页</a>
                        <a @click="pageNumGetList(pageInfo.total)">尾页</a>
                    </div>
                </div>
                <div v-if="!facilitatorListShow" class="tablelist showdomdiv showsss">
                    <div class="bgb member_box">未查到数据</div>
                </div>
            </div>
        </div>
    </div>
    <div class="lf two_left">
        <div class="about_nav">
            <ul class="widthauto">
                <li><a href="#" class="down" >账户中心</a></li>
                <p class="widthauto">
                    <a href="/index/consignor/index">我的信息</a>
                    <a href="/index/consignor/reset" >修改密码</a>
                </p>
                <li>
                    <a href="/index/consignor/facilitator"  class="cur">运力服务商</a>
                </li>
                <li>
                    <a href="/index/consignor/noticeList">我的发布</a>
                </li>
            </ul>
        </div>
        <div class="add_box"> <a href="#"><img src="/static/index/public/images/add_008.jpg" /></a> </div>
    </div>
</div>
{include file="public/footer"}
<script>
    var facilitatorMode = new Vue({
        el:'#facilitator',
        data:{
            current_page:'1',//当前页
            num:'15',//每页显示几条
            status_message:["待审核",'已通过','未通过'],
            status:0,
            member_id:'',
            facilitatorListShow:false,
            facilitatorList:[],
            pageInfo:{}
        },
        methods:{
            changeStatus:function(num){
                this.status = num
                this.current_page = 1
                this.getFacilitator()
            },
            getFacilitator:function () {
                var el = this
                var paging = {
                    "current_page":el.current_page,
                    'num':el.num
                }
                var where = {"member_info_id":el.member_id}
                if(el.status == 1){
                    where['status'] = 1
                }
                if(el.status == 2){
                    where['status'] = 2
                }
                if(el.status == 3){
                    where['status'] = 3
                }
                var postDate = {}
                if(Object.keys(where).length === 0){
                    postDate = {
                        "paging":paging,
                        "member_id": el.member_id
                    }
                }else {
                    postDate = {
                        "where":where,
                        "paging":paging,
                        "member_id": el.member_id
                    }
                }

                AjaxPost(postDate,'/index/consignor/getFacilitatorList').then((response)=>{
                    console.log(response)
                    if(response.status == 1){
                        if(response.result.list){
                            el.facilitatorListShow = true
                            el.facilitatorList = response.result.list
                            el.pageInfo = response.result.pageInfo
                        }else {
                            el.facilitatorListShow = false
                            el.facilitatorList = []

                        }

                    }
                })
            },
            pageNumGetList:function(page){
                var el = this
                el.current_page = page
                el.getFacilitator()
            },
            pageNextList:function (num) {
                var el = this;
                var set_current_page = el.current_page*1+num
                // el.current_page = el.pageInfo.current_page*1+num
                console.log(el.current_page)
                if( set_current_page < 1){
                    $.customToastr("error","已经是第一页啦");
                    return;
                }
                if(set_current_page > el.pageInfo.total){
                    $.customToastr("error","已经是最后一页啦");
                    return;
                }
                el.current_page = set_current_page
                el.getFacilitator();
            },
            updateStatus:function (item,status) {
                var item = item
                var where = {
                    'id':item.id
                }
                var data = {
                    'status':status
                }
                var postDate = {
                    'where':where,
                    'data':data
                }
                layer.confirm('确定要通过申请吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    AjaxPost(postDate,'/index/consignor/changeFacilitatorField').then((response)=>{
                        if(response.status == 1){
                            layer.close(index);
                            item.status = status
                            $.customToastr("success","通过审核");
                        }
                    })
                });
            },
            updateStatusReject:function (item,status) {
                var item = item
                var where = {
                    'id':item.id
                }
                var data = {
                    'status':status
                }
                var postDate = {
                    'where':where,
                    'data':data
                }
                layer.confirm('确定要拒绝吗？', {
                    btn: ['确定','取消'] //按钮
                }, function(index){
                    AjaxPost(postDate,'/index/consignor/changeFacilitatorField').then((response)=>{
                        if(response.status == 1){
                            layer.close(index);
                            item.status = status
                            $.customToastr("warning","该企业未通过审核");
                        }
                    })
                });
            }
        },
        mounted(){
            this.$nextTick(function () {
                this.member_id = localStorage.getItem('memberId')
                this.getFacilitator();
            })
            $(document).ready(function(){
                // $(".fortab").click(function(){
                //     var number=$(".fortab").index(this);
                //     $(this).addClass("checked");
                //     $(this).siblings().removeClass("checked");
                //     $(".tablelist:eq("+number+")").show();
                //
                //     $(".tablelist:eq("+number+")").siblings().hide();
                //
                // });

            });
        }
    })
</script>